home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 March / EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso / earcd / music / ptsupp.lha / PT Support archive / Sources / CIAShell_HW.S < prev    next >
Text File  |  1996-01-30  |  4KB  |  152 lines

  1. ;------------------------------------------------------------------------------
  2. ;
  3. ;    $VER: CIA Shell Hardware v1.1 - by Håvard "Howard" Pedersen
  4. ;    © 1994-96 Mental Diseases
  5. ;
  6. ;    A hardware-banging CIA-shell
  7. ;
  8. ;    I cannot be held responsible for any damage caused directly or in-
  9. ;    directly by this code. Still, every released version is thouroughly
  10. ;    tested with Mungwall and Enforcer, official Commodore debugging tools.
  11. ;    These programs traps writes to unallocated ram and reads/writes to/from
  12. ;    non-ram memory areas, which should cover most bugs.
  13. ;
  14. ;    HISTORY:
  15. ;
  16. ;v1.0    Simple thingy that worked with ProPruner only. Pretty nasty and thrown
  17. ;    together for the musicdisk "Hypnophone" by Compact.
  18. ;
  19. ;v1.1    Compatibility fix. Rewritten for less label confusion and compatibility
  20. ;    with my ProTracker replay.
  21. ;
  22. ;------------------------------------------------------------------------------
  23. ;
  24. ;    PUBLIC FUNCTIONS:
  25. ;
  26. ;Function:    CIA_AddCIAInt(CIASeed, VBR) (D0,A0)
  27. ;Purpose:    Attaches our interrupt to the CIAB chip, timer A. CIASeed:
  28. ;        PAL = 1773447 and NTSC = 1789773.
  29. ;
  30. ;Function:    CIA_RemCIAInt()
  31. ;Purpose:    Removes our interrupt from the CIAB chip, timer B.
  32. ;
  33. ;Function:    CIA_IntCode()
  34. ;Purpose:    Our CIA interrupt. Only callable from within an CIA interrupt.
  35. ;
  36. ;Function:    CIA_SetBPM(BPM)(D0.B)
  37. ;Purpose:    Adjusts the tempo of the current module.
  38. ;
  39. ;
  40. ;    EXTERNAL FUNCTIONS:
  41. ;
  42. ;Function:    CIA_CIAInt()
  43. ;Purpose:    Does any thingies that are necessary to perform within a CIA
  44. ;        interrupt. May trash any register.
  45. ;
  46. ;------------------------------------------------------------------------------
  47.  
  48. ; Constants. Feel free to change if you know what you're doing.
  49.  
  50. CIA_CIABase    =    $bfd000
  51. CIA_CIAVector    =    $78
  52.  
  53. ;------------------------------------------------------------------------------
  54. ;            C I A _ A D D C I A I N T
  55. ;------------------------------------------------------------------------------
  56. CIA_AddCIAInt    move.l    d0,CIA_CIASeed
  57.         move.l    a0,CIA_VBR
  58.         lea.l    $dff000,a6
  59.         move.w    #$a000,$9a(a6)        ; Enable CIA interrupt (Level6)
  60.  
  61.         move.l    CIA_CIASeed,d0
  62.         divu.w    #125,D0         ; Defaults to 125 BPM
  63.  
  64.         move.b    d0,CIA_TimerLo
  65.         lsr.w    #8,d0
  66.         move.b    d0,CIA_TimerHi
  67.     
  68.         move.l    CIA_VBR,a0
  69.         move.l    CIA_CIAVector(a0),CIA_OldIntCode
  70.         move.l    #CIA_IntCode,CIA_CIAVector(a0); Set interrupt vector
  71.  
  72.         lea.l    CIA_CIABase,a0
  73.  
  74.         move.b    #$7f,$d00(a0)        ; Stop all
  75.  
  76.         move.b    $e00(a0),d0
  77.         and.b    #%11000000,d0
  78.         or.b    #%00001011,d0
  79.         move.b    d0,$e00(a0)
  80.  
  81.         move.b    CIA_TimerLo,$400(a0)    ; Set delay
  82.         move.b    CIA_TimerHi,$500(a0)
  83.         move.b    #$81,$d00(a0)        ; Start
  84.  
  85.         rts
  86.  
  87. ;------------------------------------------------------------------------------
  88. ;            C I A _ R E M C I A I N T
  89. ;------------------------------------------------------------------------------
  90. CIA_RemCIAInt    lea.l    $dff000,a6
  91.         move    #$2000,$9a(a6)        ; Disable CIA int.
  92.  
  93.         lea    CIA_CIABase,a0
  94.         move.b    #$7f,$d00(a0)        ; Disable CIA clock
  95.         move.b    #%00011000,$e00(a0)
  96.  
  97.         move.l    CIA_VBR,a0
  98.         move.l    CIA_OldIntCode,CIA_CIAVector(a0); Restore interrupt vector
  99.  
  100.         rts
  101.  
  102. ;------------------------------------------------------------------------------
  103. ;            C I A _ I N T C O D E
  104. ;------------------------------------------------------------------------------
  105. CIA_IntCode    movem.l    d0-a6,-(sp)
  106.  
  107.         lea    CIA_CIABase,a0
  108.  
  109.         tst.b    $d00(a0)
  110.         move.b    #$7e,$d00(a0)        ; Stop some
  111.  
  112.         move.b    CIA_TimerLo,$400(a0)    ; Bestill vekking!
  113.         move.b    CIA_TimerHi,$500(a0)
  114.  
  115.         move.b    #$81,$d00(a0)        ; Start
  116.  
  117.         move.b    $e00(a0),d0
  118.         and.b    #%11000000,d0
  119.         or.w    #%00001011,d0
  120.         move.b    d0,$e00(a0)        ; ...tut & kjør!
  121.  
  122.         jsr    CIA_CIAInt
  123.  
  124. ; Legg gjerne inn mer her hvis du har lyst...
  125.  
  126.         move    #$2000,$dff09c
  127.         movem.l    (sp)+,d0-a6
  128.         rte
  129.  
  130. ;------------------------------------------------------------------------------
  131. ;            C I A _ S E T B P M
  132. ;------------------------------------------------------------------------------
  133. CIA_SetBPM    move.l    CIA_CIASeed,d1
  134.         and.w    #$ff,d0
  135.         divu.w    d0,d1
  136.  
  137.         move.b    d1,CIA_TimerLo
  138.         lsr.w    #8,d1
  139.         move.b    d1,CIA_TimerHi
  140.  
  141.         rts
  142.  
  143. ;------------------------------------------------------------------------------
  144. ;            D A T A
  145. ;------------------------------------------------------------------------------
  146. CIA_OldIntCode    dc.l    0
  147. CIA_TimerLo    dc.b    0
  148. CIA_TimerHi    dc.b    0
  149. CIA_CIASeed    dc.l    1773447
  150. CIA_VBR        dc.l    0
  151.  
  152.